﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo14
{
    class Judgment
    {
        private Player players;
        private Robot robot;

        public Judgment() {
            Console.WriteLine("请选择对方角色<1：刘备 2：孙权 3：曹操>");
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine("请输入您的名字：");
            string b = Console.ReadLine();
            players = new Player(b);
        }

        public void Play() {
            int count=0;
            while (count < 5) ;
            {
                int pFist = players.player();
                int rFist = robot.listFist();
                if (pFist == 1 && rFist == 3 || pFist == 2 && rFist == 1 || pFist == 3 || rFist == 2)
                {
                    Console.WriteLine(players.playerName() + ":此局获胜");
                    players.addScore();
                }
                else if (pFist == rFist)
                {
                    Console.WriteLine("这局平局。");
                }
                else
                {
                    Console.WriteLine(robot.RobotName() + ":此局获胜。");
                    robot.addScore();
                }
            }
            count++;
        }
        public void getResult() {
            int pScore = players.Score();
            int rScore = robot.Score();
            if (pScore > rScore)
            {
                Console.WriteLine(players.playerName() + ":最终胜利");
            }
            else if (pScore == rScore)
            {
                Console.WriteLine("平局");
            }
            else {
                Console.WriteLine(robot.RobotName()+":最终胜利");
            }
        }
        public void Start() {
            while (true)
            {
                Play();
                getResult();
                Console.WriteLine("是否继续？(y/n)");
                string a = Console.ReadLine();
                if (a == "y")
                {
                    continue;
                }
                else if (a=="n") {
                    break;
                }
            }
        }
    }
}
